package com.mdd.common.entity.zdjd.param;

import com.mdd.common.entity.zdjd.TZdjdDevice;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

@Data
@ApiModel("设备基础信息入参")
public class DeviceBasicInfoParam implements Serializable {

    @ApiModelProperty(value = "设备回传回来的唯一ID")
    private String id;

    @ApiModelProperty(value = "设备编码/设备型号")
    private String model;

    @ApiModelProperty(value = "软件版本号")
    private String swVer;

    @ApiModelProperty(value = "硬件版本号")
    private String hwVer;

    @ApiModelProperty(value = "锁定状态0:未锁定 255:锁定")
    private Integer lock;


    public static TZdjdDevice coverToTZdjdDevice(DeviceBasicInfoParam param) {
        Date now = new Date();
        Calendar calendar = Calendar.getInstance();
        TZdjdDevice device = new TZdjdDevice();
        device.setDeviceUuid(param.getId());
        device.setDeviceCode(param.getModel());
        device.setSoftwareVersion(param.getSwVer());
        device.setHardwareVersion(param.getHwVer());
        device.setLock(param.getLock());
        device.setCreateTime(now);
        device.setUpdateTime(now);
        device.setYear(String.valueOf(calendar.get(Calendar.YEAR)));
        device.setMonth(String.valueOf(calendar.get(Calendar.MONTH)+1));
        device.setDay(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        return device;
    }

}
